﻿/*
 * Created by SharpDevelop.
 * User: ley
 * Date: 5/17/2010
 * Time: 10:38 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Linq;
using System.Collections.Generic;

namespace Ley.Common.Validation
{
	[Serializable]
	public class ValidationResult
	{
		private readonly List<string> _internalList;
		
		public bool IsValid
		{
			get
			{
				return !_internalList.Any();
			}
		}
		
		public string[] Messages 
		{
			get
			{
				return _internalList.ToArray();
			}
		}
		
		public ValidationResult()
		{
			_internalList = new List<string>();
		}
		
		public void AddValidationMessage(string message)
		{
			if (!string.IsNullOrEmpty(message))
				_internalList.Add(message);
		}
		
	}
}
